#include "coordpoint.h"

CoordPoint::CoordPoint()
{
    lat = lon = 0.0;
}

CoordPoint::CoordPoint( qreal newLat, qreal newLon )
{
    lat = newLat;
    lon = newLon;
}

CoordPoint::CoordPoint(QGeoCoordinate &coord)
{
    lat = coord.latitude();
    lon = coord.longitude();
}

CoordPoint::CoordPoint(const CoordPoint& other)
{
    lat = other.lat;
    lon = other.lon;
}

QPointF CoordPoint::getPoint()
{
    return QPointF( lon,lat );
}

qreal CoordPoint::distanceFrom(const CoordPoint&b)
{
    qreal dlon = lon-b.lon;
    qreal dlat = lat-b.lat;
    return sqrt( dlon*dlon+dlat*dlat );
}

void CoordPoint::operator+=(const QPointF& pt)
{
    lat += pt.y();
    lon += pt.x();
}

void CoordPoint::operator+=(const CoordPoint& pt)
{
    lat += pt.lat;
    lon += pt.lon;
}

bool CoordPoint::operator==( const CoordPoint& b)
{
    return ( (lat==b.lat) && (lon==b.lon) );
}

bool CoordPoint::operator!=( const CoordPoint& b)
{
    return ( (lat!=b.lat) || (lon!=b.lon) );
}

